import { ElMessage } from "element-plus";
import type { Directive } from "vue";

const copy: Directive = {
  mounted(el, binding) {
    el.addEventListener("click", async () => {
      try {
        await navigator.clipboard.writeText(binding.value);
        ElMessage.success("复制成功");
      } catch (err) {
        ElMessage.error(err + "复制失败");
      }
    });
  }
};

export default copy;
